package com.boss.common.enums;

/**
 * <br>Title:工作流任务状态类型枚举
 * <br>Description:工作流任务状态类型枚举，在查询工作流使用
 * <br>Author:朱孝恒(zhuxiaoheng@bosssoft.com.cn)
 * <br>Date:2019-6-21
 */
public enum StatusCodeEnum {
    /**
     * 未走流程状态
     */
    UNDO("-1", "未走待办"),

    /**
     * 待办状态的任务
     */
    TODO("1", "待办"),
    /**
     * 待办和被退回状态的任务
     */
    TODO_BESENDBACK("1-4", "待办+被退回"),
    /**
     * 已办状态的任务
     */
    FINISHED("2", "已办（正常的已办）"),
    /**
     * 曾经办状态的任务
     */
    ONCE_FINISHED("0", "已办（即曾经办）"),
    /**
     * 退回状态的任务
     */
    BACK("3", "已退回"),
    /**
     * 被退回状态的任务
     */
    BESENDBACK("4", "被退回"),

    /**
     * 作废状态的任务
     */
    INVALID("5", "已作废"),
    /**
     * 已办结的任务
     */
    COMPLETED("6", "已办结"),

    /**
     * 待接收状态的任务
     */
    TODO_RECEIVE("8", "待接收"),
    /**
     * 录入状态的任务
     */
    INPUT("9", "录入"),

    /**
     * 撤回状态的任务
     */
    RECALL("10", "撤回（任务回收-已退回,A发起）");


    /**
     * code
     */
    private String code;
    /**
     * 名称
     */
    private String name;

    StatusCodeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }


    public String getName() {
        return name;
    }


    /**
     * 将code转换为枚举类
     * <br>Description:将code转换为枚举类，如果code不匹配则返回null
     * <br>Author:朱孝恒(zhuxiaoheng@bosssoft.com.cn)
     * <br>Date:2019-6-21
     * @param code 任务类型code
     * @return 任务类型枚举
     */
    public static StatusCodeEnum getEnum(String code) {
        if (StatusCodeEnum.UNDO.getCode().equals(code)) {
            return StatusCodeEnum.UNDO;
        }else if (StatusCodeEnum.TODO.getCode().equals(code)) {
            return StatusCodeEnum.TODO;
        } else if (StatusCodeEnum.FINISHED.getCode().equals(code)) {
            return StatusCodeEnum.FINISHED;
        } else if (StatusCodeEnum.COMPLETED.getCode().equals(code)) {
            return StatusCodeEnum.COMPLETED;
        } else if (StatusCodeEnum.ONCE_FINISHED.getCode().equals(code)) {
            return StatusCodeEnum.ONCE_FINISHED;
        } else if (StatusCodeEnum.RECALL.getCode().equals(code)) {
            return StatusCodeEnum.RECALL;
        } else if (StatusCodeEnum.BESENDBACK.getCode().equals(code)) {
            return StatusCodeEnum.BESENDBACK;
        } else if (StatusCodeEnum.INVALID.getCode().equals(code)) {
            return StatusCodeEnum.INVALID;
        } else if (StatusCodeEnum.TODO_RECEIVE.getCode().equals(code)) {
            return StatusCodeEnum.TODO_RECEIVE;
        } else if (StatusCodeEnum.INPUT.getCode().equals(code)) {
            return StatusCodeEnum.INPUT;
        } else if (StatusCodeEnum.TODO_BESENDBACK.getCode().equals(code)) {
            return StatusCodeEnum.TODO_BESENDBACK;
        } else if (StatusCodeEnum.BACK.getCode().equals(code)) {
            return StatusCodeEnum.BACK;
        } else {
            return null;
        }
    }
}
